Page({

  /**
   * 页面的初始数据
   */
  data: {
    listData:[
      {
        id:0,
        name:"家常菜",
        isActive:true
      },{
        id:1,
        name:"下饭菜",
        isActive:true
      },{
        id:2,
        name:"沙县小吃",
        isActive:true
      },{
        id:3,
        name:"一人食",
        isActive:true
      },{
        id:4,
        name:"减脂餐",
        isActive:true
      },{
        id:5,
        name:"孕期餐",
        isActive:true
      }
    ],
    inputValue:'', //输入框value值
    noData:false, //暂无数据
    carList:[],//搜索列表
  },
  search:function(e){
    var that =this;
    var inputValue=e.detail.value
    if(e.detail.value == ''){
      that.setData({
        noData:false,
        carList:'',
        closeImg:false,
      })
    }else{
      that.setData({
        closeImg:true,
      })
     wx.request({
       url: 'http://101.132.184.211:3000/like/query?name='+inputValue,
       data:{
        // search: e.detail.value
       },
       success:res=>{
        var resObj=res.data.data;
        console.log(resObj)
        console.log(e.detail.value)
       wx.navigateTo({
         url: '/pages/sousuo/sousuo?name='+inputValue,
       })
       }
     })
    }
  },
  close: function () {
    var that = this
    that.setData({
      inputValue: '',
      carList:'',
      noData:false,
      closeImg: false,
      history:true
    })
  },
 // 点击左侧菜单项选择
 selectMenu: function(e) {
   console.log(e);
  let index = e.currentTarget.dataset.index
  console.log(index)
  this.setData({
    activeIndex: index,
    toView: "a" + index,
  })
},
  /*
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.request({
      url: 'http://101.132.184.211:3000/classify?zid=下饭菜',
      success:res=>{
        console.log(res.data.data.data);
        this.setData({
          caidan:res.data.data.data,
        
        })
        
      }
      
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})
